#include<iostream>
#include<string.h>

using namespace std;

const size_t size=1024;

int main()
{
    FILE* fd=fopen("./bit","w+");
    // fd=fopen("./bit","a+");
    
    const char* ptr="linux so easy!";
    size_t n=fwrite(ptr,strlen(ptr),1,fd); //写入文件

    fseek(fd,0,SEEK_SET);     //将文件指针移到开头

    char buff[1024];
    size_t s=fread(buff,sizeof(char),1024,fd);   //返回实际读取的元素个数
    buff[s]='\0';

    cout<<buff<<endl;
    fclose(fd);
    return 0;
}